Optimal. Leaf size=187 \[ \frac {2 b^3 (A b-a B) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^4 \sqrt {a-b} \sqrt {a+b} d}-\frac {\left (a^2+2 b^2\right ) (A b-a B) \tanh ^{-1}(\sin (c+d x))}{2 a^4 d}+\frac {\left (2 a^2 A+3 A b^2-3 a b B\right ) \tan (c+d x)}{3 a^3 d}-\frac {(A b-a B) \sec (c+d x) \tan (c+d x)}{2 a^2 d}+\frac {A \sec ^2(c+d x) \tan (c+d x)}{3 a d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.50, antiderivative size = 187, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 6, integrand size = 31, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.194, Rules used = {3079, 3134,
3080, 3855, 2738, 211} \begin {gather*} \frac {2 b^3 (A b-a B) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^4 d \sqrt {a-b} \sqrt {a+b}}-\frac {(A b-a B) \tan (c+d x) \sec (c+d x)}{2 a^2 d}-\frac {\left (a^2+2 b^2\right ) (A b-a B) \tanh ^{-1}(\sin (c+d x))}{2 a^4 d}+\frac {\left (2 a^2 A-3 a b B+3 A b^2\right ) \tan (c+d x)}{3 a^3 d}+\frac {A \tan (c+d x) \sec ^2(c+d x)}{3 a d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 211
Rule 2738
Rule 3079
Rule 3080
Rule 3134
Rule 3855
Rubi steps
\begin {align*} \int \frac {(A+B \cos (c+d x)) \sec ^4(c+d x)}{a+b \cos (c+d x)} \, dx &=\frac {A \sec ^2(c+d x) \tan (c+d x)}{3 a d}+\frac {\int \frac {\left (-3 (A b-a B)+2 a A \cos (c+d x)+2 A b \cos ^2(c+d x)\right ) \sec ^3(c+d x)}{a+b \cos (c+d x)} \, dx}{3 a}\\ &=-\frac {(A b-a B) \sec (c+d x) \tan (c+d x)}{2 a^2 d}+\frac {A \sec ^2(c+d x) \tan (c+d x)}{3 a d}+\frac {\int \frac {\left (2 \left (2 a^2 A+3 A b^2-3 a b B\right )+a (A b+3 a B) \cos (c+d x)-3 b (A b-a B) \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx}{6 a^2}\\ &=\frac {\left (2 a^2 A+3 A b^2-3 a b B\right ) \tan (c+d x)}{3 a^3 d}-\frac {(A b-a B) \sec (c+d x) \tan (c+d x)}{2 a^2 d}+\frac {A \sec ^2(c+d x) \tan (c+d x)}{3 a d}+\frac {\int \frac {\left (-3 \left (a^2+2 b^2\right ) (A b-a B)-3 a b (A b-a B) \cos (c+d x)\right ) \sec (c+d x)}{a+b \cos (c+d x)} \, dx}{6 a^3}\\ &=\frac {\left (2 a^2 A+3 A b^2-3 a b B\right ) \tan (c+d x)}{3 a^3 d}-\frac {(A b-a B) \sec (c+d x) \tan (c+d x)}{2 a^2 d}+\frac {A \sec ^2(c+d x) \tan (c+d x)}{3 a d}+\frac {\left (b^3 (A b-a B)\right ) \int \frac {1}{a+b \cos (c+d x)} \, dx}{a^4}-\frac {\left (\left (a^2+2 b^2\right ) (A b-a B)\right ) \int \sec (c+d x) \, dx}{2 a^4}\\ &=-\frac {\left (a^2+2 b^2\right ) (A b-a B) \tanh ^{-1}(\sin (c+d x))}{2 a^4 d}+\frac {\left (2 a^2 A+3 A b^2-3 a b B\right ) \tan (c+d x)}{3 a^3 d}-\frac {(A b-a B) \sec (c+d x) \tan (c+d x)}{2 a^2 d}+\frac {A \sec ^2(c+d x) \tan (c+d x)}{3 a d}+\frac {\left (2 b^3 (A b-a B)\right ) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{a^4 d}\\ &=\frac {2 b^3 (A b-a B) \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^4 \sqrt {a-b} \sqrt {a+b} d}-\frac {\left (a^2+2 b^2\right ) (A b-a B) \tanh ^{-1}(\sin (c+d x))}{2 a^4 d}+\frac {\left (2 a^2 A+3 A b^2-3 a b B\right ) \tan (c+d x)}{3 a^3 d}-\frac {(A b-a B) \sec (c+d x) \tan (c+d x)}{2 a^2 d}+\frac {A \sec ^2(c+d x) \tan (c+d x)}{3 a d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(422\) vs. \(2(187)=374\).
time = 2.34, size = 422, normalized size = 2.26 \begin {gather*} \frac {\frac {24 b^3 (-A b+a B) \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2}}-6 \left (a^2+2 b^2\right ) (-A b+a B) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+6 \left (a^2+2 b^2\right ) (-A b+a B) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+\frac {a^2 (-3 A b+a (A+3 B))}{\left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}+\frac {2 a^3 A \sin \left (\frac {1}{2} (c+d x)\right )}{\left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )^3}+\frac {4 a \left (2 a^2 A+3 A b^2-3 a b B\right ) \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )}+\frac {2 a^3 A \sin \left (\frac {1}{2} (c+d x)\right )}{\left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )^3}-\frac {a^2 (-3 A b+a (A+3 B))}{\left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}+\frac {4 a \left (2 a^2 A+3 A b^2-3 a b B\right ) \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )}}{12 a^4 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.62, size = 335, normalized size = 1.79
method | result | size |
derivativedivides | \(\frac {-\frac {A}{3 a \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )^{3}}-\frac {-a A -A b +a B}{2 a^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )^{2}}+\frac {\left (-A \,a^{2} b -2 A \,b^{3}+a^{3} B +2 B a \,b^{2}\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{2 a^{4}}-\frac {2 a^{2} A +A a b +2 A \,b^{2}-B \,a^{2}-2 B a b}{2 a^{3} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}+\frac {2 b^{3} \left (A b -a B \right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{4} \sqrt {\left (a -b \right ) \left (a +b \right )}}-\frac {A}{3 a \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )^{3}}-\frac {a A +A b -a B}{2 a^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )^{2}}+\frac {\left (A \,a^{2} b +2 A \,b^{3}-a^{3} B -2 B a \,b^{2}\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 a^{4}}-\frac {2 a^{2} A +A a b +2 A \,b^{2}-B \,a^{2}-2 B a b}{2 a^{3} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}}{d}\) | \(335\) |
default | \(\frac {-\frac {A}{3 a \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )^{3}}-\frac {-a A -A b +a B}{2 a^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )^{2}}+\frac {\left (-A \,a^{2} b -2 A \,b^{3}+a^{3} B +2 B a \,b^{2}\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{2 a^{4}}-\frac {2 a^{2} A +A a b +2 A \,b^{2}-B \,a^{2}-2 B a b}{2 a^{3} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}+\frac {2 b^{3} \left (A b -a B \right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{4} \sqrt {\left (a -b \right ) \left (a +b \right )}}-\frac {A}{3 a \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )^{3}}-\frac {a A +A b -a B}{2 a^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )^{2}}+\frac {\left (A \,a^{2} b +2 A \,b^{3}-a^{3} B -2 B a \,b^{2}\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 a^{4}}-\frac {2 a^{2} A +A a b +2 A \,b^{2}-B \,a^{2}-2 B a b}{2 a^{3} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}}{d}\) | \(335\) |
risch | \(\frac {i \left (3 A a b \,{\mathrm e}^{5 i \left (d x +c \right )}-3 B \,a^{2} {\mathrm e}^{5 i \left (d x +c \right )}+6 A \,b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-6 B a b \,{\mathrm e}^{4 i \left (d x +c \right )}+12 A \,a^{2} {\mathrm e}^{2 i \left (d x +c \right )}+12 A \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}-12 B a b \,{\mathrm e}^{2 i \left (d x +c \right )}-3 A a b \,{\mathrm e}^{i \left (d x +c \right )}+3 B \,a^{2} {\mathrm e}^{i \left (d x +c \right )}+4 a^{2} A +6 A \,b^{2}-6 B a b \right )}{3 d \,a^{3} \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{3}}-\frac {b^{4} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, d \,a^{4}}+\frac {b^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) B}{\sqrt {-a^{2}+b^{2}}\, d \,a^{3}}+\frac {b^{4} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, d \,a^{4}}-\frac {b^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) B}{\sqrt {-a^{2}+b^{2}}\, d \,a^{3}}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) A b}{2 a^{2} d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) A \,b^{3}}{a^{4} d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B}{2 d a}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B \,b^{2}}{a^{3} d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) A b}{2 a^{2} d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) A \,b^{3}}{a^{4} d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B}{2 d a}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B \,b^{2}}{a^{3} d}\) | \(663\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.82, size = 729, normalized size = 3.90 \begin {gather*} \left [\frac {6 \, {\left (B a b^{3} - A b^{4}\right )} \sqrt {-a^{2} + b^{2}} \cos \left (d x + c\right )^{3} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right ) + 3 \, {\left (B a^{5} - A a^{4} b + B a^{3} b^{2} - A a^{2} b^{3} - 2 \, B a b^{4} + 2 \, A b^{5}\right )} \cos \left (d x + c\right )^{3} \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, {\left (B a^{5} - A a^{4} b + B a^{3} b^{2} - A a^{2} b^{3} - 2 \, B a b^{4} + 2 \, A b^{5}\right )} \cos \left (d x + c\right )^{3} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (2 \, A a^{5} - 2 \, A a^{3} b^{2} + 2 \, {\left (2 \, A a^{5} - 3 \, B a^{4} b + A a^{3} b^{2} + 3 \, B a^{2} b^{3} - 3 \, A a b^{4}\right )} \cos \left (d x + c\right )^{2} + 3 \, {\left (B a^{5} - A a^{4} b - B a^{3} b^{2} + A a^{2} b^{3}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{12 \, {\left (a^{6} - a^{4} b^{2}\right )} d \cos \left (d x + c\right )^{3}}, -\frac {12 \, {\left (B a b^{3} - A b^{4}\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \cos \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (d x + c\right )}\right ) \cos \left (d x + c\right )^{3} - 3 \, {\left (B a^{5} - A a^{4} b + B a^{3} b^{2} - A a^{2} b^{3} - 2 \, B a b^{4} + 2 \, A b^{5}\right )} \cos \left (d x + c\right )^{3} \log \left (\sin \left (d x + c\right ) + 1\right ) + 3 \, {\left (B a^{5} - A a^{4} b + B a^{3} b^{2} - A a^{2} b^{3} - 2 \, B a b^{4} + 2 \, A b^{5}\right )} \cos \left (d x + c\right )^{3} \log \left (-\sin \left (d x + c\right ) + 1\right ) - 2 \, {\left (2 \, A a^{5} - 2 \, A a^{3} b^{2} + 2 \, {\left (2 \, A a^{5} - 3 \, B a^{4} b + A a^{3} b^{2} + 3 \, B a^{2} b^{3} - 3 \, A a b^{4}\right )} \cos \left (d x + c\right )^{2} + 3 \, {\left (B a^{5} - A a^{4} b - B a^{3} b^{2} + A a^{2} b^{3}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{12 \, {\left (a^{6} - a^{4} b^{2}\right )} d \cos \left (d x + c\right )^{3}}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\left (A + B \cos {\left (c + d x \right )}\right ) \sec ^{4}{\left (c + d x \right )}}{a + b \cos {\left (c + d x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 412 vs.
\(2 (170) = 340\).
time = 0.48, size = 412, normalized size = 2.20 \begin {gather*} \frac {\frac {3 \, {\left (B a^{3} - A a^{2} b + 2 \, B a b^{2} - 2 \, A b^{3}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{a^{4}} - \frac {3 \, {\left (B a^{3} - A a^{2} b + 2 \, B a b^{2} - 2 \, A b^{3}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{a^{4}} + \frac {12 \, {\left (B a b^{3} - A b^{4}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{\sqrt {a^{2} - b^{2}} a^{4}} - \frac {2 \, {\left (6 \, A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 3 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 3 \, A a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 6 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 6 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 4 \, A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 12 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 12 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 6 \, A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 3 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 3 \, A a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 6 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{3} a^{3}}}{6 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 4.90, size = 2500, normalized size = 13.37 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________